﻿$(function () {
    var i = 2;

    $("#themHang").live("click", function (e, index) {
        $("#themLienDoan tbody >tr:last").after(' <tr><td><input type="text" id="tenliendoan" name="tenliendoan" /></td>'
            +'<td><input type="text" id="truong1" name="truong1" /></td>'+
                        '<td><input type="email" id="email1" name="email1" /></td>'
                        +'<td><input type="button" id="themHang" name="themHang"  value="Thêm" /></td>'
                    + '<td><input type="button" id="xoaHang" name="xoaHang"  value="Xóa" /></td></tr>');
         $('#themLienDoan  tbody > tr:last').prev().find("input[name='themHang']").remove();
    });

    $("#xoaHang").live("click", function (e) {

        if ($('#themLienDoan  tbody > tr').length <= 1) {

            return false;

        }

        if ($(this).parent().parent().find("input[name='themHang']").val()) {

            return false;

        }

        if (confirm("Bạn có muốn xóa không ?")) {

            $(this).parent().closest("tr").css("background-color", "#FFFFEA");

            $(this).fadeOut('slow', function () {

                $(this).parent().closest("tr").remove();

            });

        }

    });

});

$(".boKhoangTrang").keypress(function (event) {
    if (event.keyCode == 32) {
        return false;
    } else {
        return true;
    }
});

$(".scout-calendar").datepicker({
    changeMonth: true,
    changeYear:true
});
